


from analyse.kline_handler.enum import ShadowType
from analyse.kline_handler.handler import KlineHandler


class ShadowHandler(KlineHandler):
    def handle(self, kline):
        body=kline["body"]
        upper_shadow=kline["upperShadow"]
        lower_shadow=kline["lowerShadow"]
        ratio_us_body=0
        ratio_ls_body=0
        ratio_us_ls=0
        ratio_ls_us=0
        if body>0:
            ratio_us_body=upper_shadow/body
            ratio_ls_body=lower_shadow/body

        if upper_shadow==0 and lower_shadow==0:
            self.compound_kline_type(kline,ShadowType.全秃.value*1000)
        elif upper_shadow>0 and lower_shadow==0:
            self.compound_kline_type(kline,ShadowType.光头.value*1000)
        elif upper_shadow==0 and lower_shadow>0:
            self.compound_kline_type(kline,ShadowType.赤脚.value*1000)
        elif upper_shadow>0 and lower_shadow>0:
            ratio_us_ls=upper_shadow/lower_shadow
            ratio_ls_us=lower_shadow/upper_shadow
            self.compound_kline_type(kline,ShadowType.影线.value*1000)

        kline["ratio_us_body"]=ratio_us_body
        kline["ratio_ls_body"]=ratio_ls_body
        kline["ratio_us_ls"]=ratio_us_ls
        kline["ratio_ls_us"]=ratio_ls_us

        

        